package com.example.activemq;

import org.apache.activemq.command.ActiveMQQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

import javax.jms.Destination;

@Service
public class Product {

    Logger logger = LoggerFactory.getLogger(Product.class);

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    public void sendMessage(String destinationName,String message) {

        logger.info("发送消息：{}==>{}",message,destinationName);

        Destination destination = new ActiveMQQueue(destinationName);
        this.jmsMessagingTemplate.convertAndSend(destination, message);
    }

}
